# -*- coding: utf-8 -*-

import torndb
import redis
import setting
import logging

logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(name)s %(levelname)s lineno:%(lineno)d %(message)s")
logger = logging.getLogger('mq.consumer')

class BaseConsumer(object):

    def __init__(self):

        self.db = torndb.Connection(
            host=setting.mysql_host,
            database=setting.mysql_database,
            user=setting.mysql_user,
            password=setting.mysql_password,
            time_zone="+8:00",
            charset='utf8mb4',
            max_idle_time=900,
            connect_timeout=900
        )

        self.redis = redis.StrictRedis(host=setting.redis_host, port=setting.redis_port, db=1)

        self.init()
